package com.qen.truelicense;

import com.qen.truelicense.license.License;
import com.qen.truelicense.license.LicenseCreatorDemo;
import com.qen.truelicense.license.LicenseExtraModel;

import java.util.Date;

// 按两次 Shift 打开“随处搜索”对话框并输入 `show whitespaces`，
// 然后按 Enter 键。现在，您可以在代码中看到空格字符。
public class QuickMain {
    public static void main(String[] args) {
        // 生成license需要的一些参数
        License param = new License();
        param.setIssued(new Date());
        LicenseExtraModel model = new LicenseExtraModel();
        String alias = "privatekey";
        param.setPrivateAlias(alias);
        String keypwd = "qen123";
        param.setKeyPass(keypwd);
        String storepwd = "qen123";
        param.setStorePass(storepwd);
        String subject = "XUHUO";
        param.setSubject(subject);
        String licpath = "/data/license.lic";
        param.setLicensePath(licpath);
        String priPath = "/data/privatekeys.store";
        // 私钥库所在地址
        param.setPrivateKeysStorePath(priPath);

        param.setNotBefore(new Date());

        param.setNotAfter(StringUtils.str2Date(StringUtils.addDay(new Date(), 365), "yyyy-MM-dd"));
        model.setMachineCode(null);

        model.setMacAddress("00:e0:4c:36:69:40");
        param.setConsumerType("user");

        param.setConsumerAmount(1);
        model.setUserNumber(1);

        // 描述
        param.setDescription("测试使用");
        param.setLicenseExtraModel(model);

        LicenseCreatorDemo licenseCreator = new LicenseCreatorDemo(param);
        // 生成license
        licenseCreator.generateLicense();
    }

}